package com.yehuishou.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yehuishou.dao.HUserDao;
import com.yehuishou.pojo.HUser;
import com.yehuishou.service.AdminService;
/**
 * 
 * @author zxb
 *
 */
@Service
public class AdminServiceImpl implements AdminService {

	@Autowired
	private HUserDao huserDao;
	
	@Override
	public List<HUser> findAll() {
		List<HUser> list = huserDao.findAll();
		return list;
	}

	@Override
	public List<HUser> findBy(String uphone, String nickname) {
		List<HUser> list = huserDao.findBy(uphone,nickname);
		return list;
	}

	@Override
	public void adminDel(Integer h_uid) {
		if(h_uid!=1) {
			//刪除用戶
			huserDao.adminDel(h_uid);
			//删除权限
			huserDao.adminDelPer(h_uid);
		}
	}

	@Override
	public void HUserUpdate(HUser huser) {
		huserDao.HUserUdate(huser);
	}

	@Override
	public int adminAdd(HUser huser) {
		
		Integer h_uid = huserDao.adminAdd(huser);
		
		return h_uid ;
	}

	@Override
	public HUser findByUName(String uname) {
		return huserDao.findByUname(uname);
	}

}
